package com.markerhub.controller;


import com.markerhub.common.lang.Result;
import com.markerhub.entity.User;
import com.markerhub.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author springboot vue
 * @since 2021-03-01
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * @RequiresAuthentication会限制访问
     * @return
     */
    @RequiresAuthentication
    @GetMapping("/index")
    public Result indexController(){
        User user=userService.getById(1);
        return Result.success(user);
    }

    @PostMapping("/test")
    public Result testController(@Validated @RequestBody User user){
        return Result.success(user);
    }

}
